<?php
App::uses('Tetel', 'Model');

class TetelTest extends CakeTestCase {
	public $fixtures = array('app.tetel', 'app.bizonylat', 'app.naplo', 'app.szamla');
	
	public function setUp() {
		parent::setUp();
		$this->Tetel = ClassRegistry::init('Tetel');	//ezzel biztosítjuk, hogy használja az AB kapcsolatot
	}
	
	public function testGetEgyenlegNoBizonylat(){
		$actual = $this->Tetel->getEgyenleg(1, 2012);
		$expected = array(
			'tegyenleg' => '50000.00',
			'kegyenleg' => '13250.00'
		);
		$this->assertEquals($expected, $actual);
	}

	public function testGetEgyenlegWithBizonylat(){
		$actual = $this->Tetel->getEgyenleg(1, 2012, 5);
		$expected = array(
			'tegyenleg' => '50000.00',
			'kegyenleg' => '5300.00'
		);
		$this->assertEquals($expected, $actual);
	}
	
	public function testGetLastKonyveltDatum(){
		Cache::clear();
		$actual = $this->Tetel->getLastKonyveltDatum(381, array('ev' => 2012, 'cegId' => 1));
		$expected = '2012-11-18';
		$this->assertEquals($expected, $actual);
	}
	
	public function testGetOsszesLaksmi(){
		$actual = $this->Tetel->getOsszes(38, array('ev' => 2012, 'cegId' => 1));
		$expected = 40910;
		$this->assertEquals($expected, $actual);
	}

	public function testGetOsszesTartozas(){
		$actual = $this->Tetel->getOsszes('451*-452*+454', array('ev' => 2012, 'cegId' => 2));
		$expected = 33000;
		$this->assertEquals($expected, $actual);
	}

	public function testGetOsszesKoveteles(){
		$actual = $this->Tetel->getOsszes('364*-365*+311', array('ev' => 2012, 'cegId' => 2));
		$expected = -21700;
		$this->assertEquals($expected, $actual);
	}
}
?>